#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	vector<vector<int>> v(n, vector<int>(m));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> v[i][j];
		}
	}

	for (int i = 0; i < m; i++)
	{
		for (int j = n - 1; j >= 0; j--)
		{
			cout << v[j][i] << ' ';
		}
		cout << endl;
	}
	cout << endl;

	
	return 0;
}